// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import moment from 'moment';
import store from './store';
import router from './router';
import AmapVue from '@amap/amap-vue';
import Vant from 'vant/es';
import 'vant/lib/index.css';
import ant from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import '@/assets/icon/iconfont.js';
import '@/assets/style/reset.scss';
import VueAMap from "vue-amap";
import md5 from 'js-md5';
import Cookies from 'js-cookie';
// import VueCookies from 'vue-cookies';
import VueCookies from 'vue-cookie';
import { getPosition } from "./components/Msite/Model/getPosition.js";
import { getOrderList } from "./api/index";
// Vue.use(getPosition(this.trajectory, this.orderId, this.userId));

Vue.use(VueAMap);

Vue.use(Vant);
Vue.use(ant);
Vue.config.productionTip = false;
Vue.prototype.$moment = moment;
Vue.prototype.$md5 = md5;
Vue.prototype.$Cookies = Cookies;
Vue.prototype.$cookie = VueCookies;
Vue.use(AmapVue);

setInterval(() => {
  if(Cookies.get('userId') !== undefined) {
    getOrderList(Cookies.get('userId'), 0).then(({data}) => {
      if(data.data.length !== 0) {
        console.log('---------------当前已经登录，而且有订单，所以可以获取经纬度-------------------');
        if(data.data[0].trajectory === null) {
          Vue.prototype.getPosition = getPosition([], data.data[0].id);
        }else {
          Vue.prototype.getPosition = getPosition(data.data[0].trajectory, data.data[0].id);
        }
      }else {
        console.log('---------------当前已经登录，但是没有订单，所以不能获取经纬度--------------');
      }
    })
  }
}, 5000);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
});
